
{% extends "base_navigation.html" %}
{% load static %}
{% load extra_filters %}

<head>
    {% block head_part %}
        <title>文件管理</title>
        <link rel="stylesheet" href="{% static 'Form_Style/css/style-nav.css' %}">
        <link rel="stylesheet" href="{% static 'index/css/index.css' %}">
    {% endblock %}
</head>
<body>
    {% block user_who %}| User：{{ username }}{% endblock user_who %}
    {% block body_part %}
{#        transform导致页面上下扩张#}
{#        top:0;margin-top:230px;padding-top: 15%;#}
        <article style="left:0;top:10%;">
            <div class="inner-wrapper" >

        {#        <div class="header">#}
        {#            <h1>{{ user.username | capitalize }}'s Webdrive</h1>#}
        {#        </div>#}

                <div class="user-info">
                    <p class="user-bar">
                        <span class="user-info username">{{ username }}</span>
                        <span class="user-info"><a href="{% url 'file_manage:setting' %}">设置</a></span>
{#                        <span class="user-info"><a href="{% url 'myapp:logout' %}">登出</a></span>#}
                        <span class="user-info">|</span>
                        {% if is_file %}
{#                            <span class="user-info"><a href="{% url 'myapp:edit' file.pk %}">重命名</a></span>#}
{#                            <span class="user-info"><a href="{% url 'myapp:download' file.pk %}">下载</a></span>#}
{#                            <span class="user-info"><a href="{% url 'myapp:delete' file.pk %}">删除</a></span>#}
                             <span class="user-info"><a href="{% url 'file_manage:edit' file.pk %}">重命名</a></span>
                             <span class="user-info"><a href="{% url 'file_manage:move_file' file.pk %}">移动文件</a></span>
                             <span class="user-info"><a href="{% url 'file_manage:download' file.pk %}">下载文件</a></span>
                             <span class="user-info"><a href="{% url 'file_manage:delete' file.pk %}">删除文件</a></span>
                            <span class="user-info"><a href="{% url 'file_manage:bind_mail' file.pk %}">绑定邮箱</a></span>
                             <span class="user-info"><a href="{% url 'file_manage:gen_html_process' file.pk %}">run总用例</a></span>
                            <span class="user-info"><a href="{% url 'file_manage:timed_task' file.pk %}">定时任务</a></span>
                        {% else %}
{#                            <span class="user-info"><a href="{% url 'myapp:mkdir' directory.pk %}">新建</a></span>#}
{#                            <span class="user-info"><a href="{% url 'myapp:rmdir' directory.pk %}">删除</a></span>#}
                              <span class="user-info"><a href="{% url 'file_manage:mkdir' directory.pk %}">新建文件夹</a></span>
                              <span class="user-info"><a href="{% url 'file_manage:rmdir' directory.pk %}">删除文件夹</a></span>
                        {% endif %}
                    </p>
                </div>

{#                仅在是目录的情况下#}
                {% if not is_file %}
                    <div class="upload-info">
                        <form enctype="multipart/form-data" method="post" action="{% url 'file_manage:upload' %}">
                            {% csrf_token %}
                            {{ form }}
                            <span id="custom-text">未选择任何文件</span>
                            <button class="btn" id="custom-button">选择文件</button>
                            <button class="btn" id="custom-submit">上传文件</button>
                        </form>
                    </div>
                {% endif %}

                <div class="dir-info">
{#                    搜索目录或者文件概况#}
                    <span>「{% if is_file %}文件{% else %}目录{% endif %}」：</span>
                    <span>
                        / <a href="{% url 'file_manage:index' %}">{{ username }}</a>
                        {% if is_file %}
                            {% path file True %}
                        {% else %}
                            {% path directory False %}
                        {% endif %}
                    </span>
                </div>

                <div class="file-info">

                    {% if is_file %}
{#                        在文件的情况下显示#}
                            <div class="preview" id="preview">

                            </div>
                            <table class="file" align="left">
                                <tr>
                                    <th>属性</th>
                                    <th>值</th>
                                </tr>
                                <tr>
                                    <td>文件名</td>
                                    <td>{{ file.name }}</td>
                                </tr>
                                <tr>
                                    <td>文件大小</td>
                                    <td>{{ file.get_size }}</td>
                                </tr>
                                <tr>
                                    <td>上传时间</td>
                                    <td>{{ file.datetime | date:'Y年m月d日 H:i:s' }}</td>
                                </tr>
                                <tr>
                                    <td>上传者</td>
                                    <td><a href="">{{ file.owner }}</a></td>
                                </tr>
                                <tr>
                                    <td>SHA1 摘要</td>
                                    <td>{{ file.digest }}</td>
                                </tr>
                            </table>
                    {%  else %}
{#                             当在目录的情况下显示#}
                            <ul>
                                {% for directory in directory.directory_set.all %}
                                    <li>
                                        <a  class="directory" href="{{ directory.get_url }}">{{ directory.name }}</a>
                                    </li>
                                {% endfor %}

                                {% for file in directory.file_set.all %}
                                    <li><a class="file" href="{{ file.get_url }}">{{ file.name }}</a></li>
                                {% endfor %}
                            </ul>
                    {% endif %}
                </div>
            </div>
            <script  src="{% static 'Form_Style/download_js/script-nav.js' %}"></script>
        </article>

        <script type="text/javascript" src="{% static 'index/js/jquery-3.3.1.js' %}"></script>
        <script type="text/javascript">

    $(function(){
                {#$.get("/preview/{{ file.pk }}?thumbnail=True",#}
                $.get('/{{ file.pk }}/preview',
                    function(result) {
                        $("#preview").html(result);
                });
       });
    </script>
        {% if not is_file %}
            <script type="text/javascript" src="{% static 'index/js/upload.js' %}"></script>
        {% endif %}
{#        消息框架#}
	{% if messages %}
    <script>
        {% for msg in messages %}
            alert('{{ msg.message }}');
        {% endfor %}
    </script>
	{% endif %}
{% endblock %}



</body>









